//获取应用实例
var app = getApp()
Page({
  data: {
    knowledgeId:"",
    knowledge:"",
    count:0
  },

  onLoad: function (options) {
    this.setData({
      knowledgeId: options.knowledgeId,
    })
    this.getKnowledge()
  },

  getKnowledge: function () {
    var that = this
    if (this.data.knowledgeId != "") {
      wx.request({
        url: 'https://eis.natappvip.cc/ITSupport/knowledge_getKnowledgeById.action',
        data: {
          'knowledge.knowledgeId': this.data.knowledgeId,
        },
        header: {
          'Content-Type': 'application/json'
        },
        success: function (res) {
          let jsonresult = JSON.parse(res.data)
          console.log(jsonresult.result)
          if (jsonresult.result == "success") {
            that.setData({
              knowledge: jsonresult.knowledge,
              count: jsonresult.count,
            })
          }
        },
        fail: function (res) {
          console.log("failed:" & res)
        }
      })
    }
  },

  preview: function (e) {
    this.setData({
        knowledgeId: e.currentTarget.dataset.knowledgeId - 1,
    })
    this.getKnowledge()
  },

  next: function (e) {
    this.setData({
      knowledgeId: e.currentTarget.dataset.knowledgeId + 1,
    })
    this.getKnowledge()
  },

})
